// 封装ajax方法，方便调用
let baseUrl = 'http://localhost:8080/api/v1';
function myAjax(type, url, data, callback) {
    let judgeformData = data instanceof FormData;
    $.ajax({
        type: type,
        url: baseUrl + url,
        // 除了登录外，其余任何请求都要带上headers
        contentType: judgeformData ? false : 'application/x-www-form-urlencoded',
        processData: judgeformData ? false : true,
        headers: {
            Authorization: localStorage.getItem('login_toke')
        },
        data: data,
        success: function (resData) {
            if (resData.code === 403) {
                // window.parent:返回当前窗口的父窗口
                window.parent.location = './login.html';
                return;
            }
            callback(resData);
        }
    })
}